﻿Imports System.Windows.Forms

Public Class frmTime

    Public strTime As String

#Region "Eventi form"

    Private Sub frmOrario_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        For i As Integer = 0 To 23
            cboOra.Items.Add(i)
        Next
        For i As Integer = 0 To 59
            cboMinuti.Items.Add(i)
        Next
        cboOra.Text = Now.Hour
        cboMinuti.Text = Now.Minute
    End Sub

    Private Sub Me_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Me.Top = Control.MousePosition.Y - 165 + Me.Height
        Me.Left = Control.MousePosition.X

        Me.BringToFront()
    End Sub

    Private Sub me_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then
            strTime = ""
            Me.DialogResult = DialogResult.Cancel
        End If
    End Sub

#End Region

#Region "Comandi"

    Private Sub cmdAnnulla_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAnnulla.Click
        Me.DialogResult = DialogResult.Cancel
    End Sub

    Private Sub cmdContinua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdContinua.Click
        strTime = Format(CInt(cboOra.Text), "00") & ":" & Format(CInt(cboMinuti.Text), "00")
        Me.DialogResult = DialogResult.OK
    End Sub

#End Region

End Class